#include "tjc.h"
#include "xuc.h"
#include "string.h"

void TJC::Init(UART* huart, USART_TypeDef* Instance, const uint32_t BaudRate)
{
	huart->Init(Instance, BaudRate).DMARxInit();// .DMATxInit();
	m_uart = huart;
	queueHandler = &huart->UartQueueHandler;
}

void TJC::show_txt()
{
	if (able2send)// && (!sent))
	{
		//sent = true;
		memcpy(tx_buffer, &hex_data, sizeof(hex_data));
		m_uart->UARTTransmit(tx_buffer, sizeof(hex_data));
	}
}

void TJC::update_data()
{
	if (xuc.qrcodedata.num1 != 0)
	{
		scan_ok = true;
	}

	if (scan_ok)
	{
		hex_data[8] = xuc.pickindex[0][0] + 0x30;
		hex_data[9] = xuc.pickindex[0][1] + 0x30;
		hex_data[10] = xuc.pickindex[0][2] + 0x30;

		hex_data[12] = xuc.pickindex[1][0] + 0x30;
		hex_data[13] = xuc.pickindex[1][1] + 0x30;
		hex_data[14] = xuc.pickindex[1][2] + 0x30;

		able2send = true;
	}
}